Skip to content

Comments

[ENGG-5312] fix: Fix import for records with duplicate names#290

Open
ajinkya-browserstack wants to merge 1 commit intomasterfrom
ENGG-5312-fix-import
Open

[ENGG-5312] fix: Fix import for records with duplicate names#290
ajinkya-browserstack wants to merge 1 commit intomasterfrom
ENGG-5312-fix-import

Conversation

@ajinkya-browserstack
Copy link
Contributor

@ajinkya-browserstack ajinkya-browserstack commented Feb 13, 2026

Case comparison for baseName: "Untitled request" (hardcoded) vs baseName: sanitizedName:

Case 1: baseName hardcoded to Untitled request

  • Only names that look like Untitled request, Untitled request1, etc. get auto-renamed.
  • Untitled request → Untitled request1 works.
  • Login when Login already exists does not become Login1; it fails with Record already exists.
  • Untitled Request (different case) when Untitled request exists also fails with Record already exists.

Case 2: baseName set to sanitizedName

  • We always use the actual sanitized name as the base for conflicts.
  • Untitled request still becomes Untitled request1, Untitled request2, etc.
  • Login when Login exists becomes Login1, then Login2, etc.
  • My: API? when sanitized to My_ API_ and My_ API_ exists becomes My_ API_1.
  • Untitled Request when Untitled request exists becomes Untitled Request1 instead of failing.

Summary by CodeRabbit

Release Notes

  • Bug Fixes

    • Name conflict detection now uses case-insensitive comparison when creating records, environments, and collections.
  • Refactor

    • Standardized name sanitization logic across record, environment, and collection creation workflows for improved consistency.

@linear
Copy link

linear bot commented Feb 13, 2026

@coderabbitai
Copy link

coderabbitai bot commented Feb 13, 2026

Walkthrough

This change enhances name conflict resolution by implementing case-insensitive name matching and standardizing name sanitization logic. In common-utils.ts, the isNewEntityName function now uses case-insensitive regex matching, and getAlternateName performs lowercase comparisons when checking for name conflicts while preserving original casing in results. In fs-manager.ts, name sanitization is consolidated across three functions—createRecord, createEnvironment, and createCollectionFromCompleteRecord—eliminating duplicate sanitization steps and hard-coded default names, resulting in a unified approach to handling name conflicts during import operations.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically describes the main change: fixing imports for records with duplicate names, which aligns with the case-insensitive comparison updates and name conflict handling improvements in the changeset.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Merge Conflict Detection ✅ Passed ✅ No merge conflicts detected when merging into master

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch ENGG-5312-fix-import

No actionable comments were generated in the recent review. 🎉

🧹 Recent nitpick comments
src/renderer/actions/local-sync/fs-manager.ts (1)

1485-1498: Redundant double sanitization on Line 1498.

collection.name is already set to newName (Line 1494), which originates from sanitizedName (Line 1485) — either directly or with appended digits from getAlternateName. Calling sanitizeFsResourceName again on Line 1498 is redundant. Compare with createCollection (Line 898) which uses name directly without re-sanitizing.

Not a bug (digits won't introduce invalid chars), but worth aligning for consistency.

♻️ Suggested fix
     const path = appendPath(
       parentPath,
-      sanitizeFsResourceName(collection.name)
+      collection.name
     );

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants